
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module vcard-manager
* @author: Hjava
* @description: 名片管理模块
* @since: 2018-07-23 12:56:13
*/
var promise_1 = __webpack_require__(/*! _util/promise */ "./src/core/utils/promise.ts");
var log_1 = __webpack_require__(/*! ./../utils/log */ "./src/extra/utils/log.ts");
var VcardManager = /** @class */ (function () {
    function VcardManager() {
        this.mtdx = null;
    }
    VcardManager.prototype.init = function (mtdx) {
        log_1.default.log('VcardManager::init');
        this.mtdx = mtdx;
    };
    VcardManager.prototype.getUserVcard = function (uids) {
        var _this = this;
        if (uids === void 0) { uids = []; }
        if (!Array.isArray(uids) || uids.length === 0) {
            return promise_1.default.resolve([]);
        }
        return new promise_1.default(function (resolve, reject) {
            var dataObject = { ul: uids };
            log_1.default.info('VcardManager::getUserVcard info:' + JSON.stringify(dataObject));
            _this.mtdx.HTTP.Vcard.getUserVcard({
                data: dataObject,
                success: function (_a) {
                    var rescode = _a.rescode, data = _a.data;
                    if (rescode === 0) {
                        resolve(data);
                    }
                    else {
                        log_1.default.info('VcardManager::getUserVcard fail info:' + rescode);
                        reject(rescode);
                    }
                },
                error: function (e) {
                    log_1.default.info('VcardManager::getUserVcard fail info:' + e);
                    reject(e);
                }
            });
        });
    };
    VcardManager.prototype.getPubVcard = function (uids) {
        var _this = this;
        if (!Array.isArray(uids) || uids.length === 0) {
            return promise_1.default.resolve([]);
        }
        return new promise_1.default(function (resolve, reject) {
            var dataObject = { pubIds: uids };
            log_1.default.info('VcardManager::getPubVcard info:' + JSON.stringify(dataObject));
            _this.mtdx.HTTP.Vcard.getPubVcard({
                data: dataObject,
                success: function (_a) {
                    var rescode = _a.rescode, data = _a.data;
                    if (rescode === 0) {
                        resolve(data);
                    }
                    else {
                        log_1.default.info('VcardManager::getPubVcard fail info:' + rescode);
                        reject(rescode);
                    }
                },
                error: function (e) {
                    log_1.default.info('VcardManager::getPubVcard fail info:' + e);
                    reject(e);
                }
            });
        });
    };
    VcardManager.prototype.getGroupVcard = function (uids) {
        var _this = this;
        if (uids === void 0) { uids = []; }
        if (!Array.isArray(uids) || uids.length === 0) {
            return promise_1.default.resolve([]);
        }
        return new promise_1.default(function (resolve, reject) {
            var dataObject = { gul: uids };
            log_1.default.info('VcardManager::getGroupVcard info:' + JSON.stringify(dataObject));
            _this.mtdx.HTTP.Vcard.fetchGroup({
                data: dataObject,
                success: function (_a) {
                    var rescode = _a.rescode, data = _a.data;
                    if (rescode === 0) {
                        resolve(data);
                    }
                    else {
                        log_1.default.info('VcardManager::getGroupVcard fail info:' + rescode);
                        reject(rescode);
                    }
                },
                error: function (e) {
                    log_1.default.info('VcardManager::getGroupVcard fail info:' + e);
                    reject(e);
                }
            });
        });
    };
    return VcardManager;
}());
exports.default = new VcardManager();


//# sourceURL=webpack://MTDX/./src/extra/managers/vcard-manager.ts?